package com.ziyun.ureport.datasource;

import com.bstek.ureport.definition.datasource.BuildinDatasource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;

/**
 * @author zh
 * @date 2018/8/1613:15
 */
@Component
public class UreportDataSource implements BuildinDatasource {
    private static final String NAME = "MyDataSource";

    @Autowired
    private DataSource dataSource;

    @Override
    public String name() {
        return NAME;
    }

    @Override
    public Connection getConnection() {
        try {
            return dataSource.getConnection();
        } catch (SQLException e) {
            System.out.println("Ureport 数据源 获取连接失败！");
            e.printStackTrace();
        }
        return null;
    }
}
